package com.guet.main.controller;


import com.guet.common.utils.R;
import com.guet.main.entity.Test;
import com.guet.main.service.TestService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * test 前端控制器
 * </p>
 *
 * @author csp
 * @since 2022-07-12
 */
@RestController
@RequestMapping("/main/test")
@CrossOrigin
public class TestController {

    private final TestService testService;

    public TestController(TestService testService) {
        this.testService = testService;
    }

    @ApiOperation(value = "测试列表")
    @GetMapping("/list")
    public R list(){
        List<Test> list = testService.list(null);
        return R.ok().data("msg",list);
    }

    @ApiOperation(value = "测试添加")
    @PostMapping("/add")
    public R add(@RequestBody Test test){
        boolean save = testService.save(test);
        return save?R.ok():R.error();
    }
}

